function DecodeTGA(src, reportError, reportLoad)
{
    var dataView = new DataView(src);
    var imageType = dataView.getUint8(2);
    if (imageType !== 2) {
        reportError("TGA: invalid ImageType");
        return;
    }

    var width = dataView.getUint16(12, true);
    var height = dataView.getUint16(14, true);
    var pixelDepth = dataView.getUint8(16);
    var imageDescriptor = dataView.getUint8(17);

    if (pixelDepth !== 32) {
        reportError("TGA: not support pixel bit:" + pixelDepth);
        return;
    }

    var rgba8888Data = new Uint8Array(src, 18, width * height * 4);
    var index;
    var temp;
    var i;
    var l;

    // BGRA -> RGBA
    for (i = 0, l = width * height; i < l; i++) {
        var index = i * 4;
        temp = rgba8888Data[index];

        rgba8888Data[index] = rgba8888Data[index + 2];
        rgba8888Data[index + 2] = temp;
    }

    reportLoad(width, height, rgba8888Data);
}
